package com.yonyou.pmclouds.organization.mapper;

import com.yonyou.pmclouds.basecom.dao.BaseMapper;
import com.yonyou.pmclouds.organization.entity.RoleDistributeVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface RoleDistributeMapper extends BaseMapper<RoleDistributeVO> {

    @Select("select * from pm_roledistribute where pk_tenant = #{pkTenant} and dr = 0 order by creationtime desc")
    RoleDistributeVO[] getRoleDistribute(@Param("pkTenant") String pkTenant);

    @Select("select * from pm_roledistribute where pk_tenant = #{pkTenant} and pk_role in (${pkRoles}) and dr = 0 order by creationtime desc")
    RoleDistributeVO[] getByPkRoles(@Param("pkTenant") String pkTenant, @Param("pkRoles") String pkRoles);

    @Select("select count(*) from pm_roledistribute where pk_tenant = #{pkTenant} and pk_role in (${pkRoles}) and dr = 0")
    int countRoleByIds(@Param("pkTenant") String pkTenant, @Param("pkRoles") String pkRoles);
}
